<template>
    <div class="container">
        <detail-banner :sightName="sightName" :bannerImg="bannerImg" :gallaryImgs="gallaryImgs"></detail-banner>
        <detail-header></detail-header>
        <div class="content">
           <detail-list :list="List"></detail-list>
        </div>
    </div>
</template>

<script>
import DetailBanner from './components/Banner'
import DetailHeader from './components/Header'
import DetailList from './components/List'
import axios from 'axios'
export default {
  name: 'Detail',
  components: {
    DetailBanner,
    DetailHeader,
    DetailList
  },
  data () {
    return {
      sightName: '',
      bannerImg: '',
      gallaryImgs: [],
      List: []
      // List: [{
      //   title: '成人票',
      //   children: [{
      //     title: '成人票一等座',
      //     children: [{
      //       title: '成人票一等座--1'
      //     }]
      //   }, {
      //     title: '成人票二等座'
      //   }]
      // }, {
      //   title: '学生票'
      // }, {
      //   title: '儿童票'
      // }, {
      //   title: '特惠票'
      // }]
    }
  },
  methods: {
    getDetailInfo () {
      // axios.get('/api/detail.json?id=' + this.$route.params.id)获取动态路由，URL传过来的值（第一种写法）
      // 如下为第二种写法
      axios.get('/api/detail.json', {
        params: {
          id: this.$route.params.id
        }
      }).then(this.getDetailSucc)
    },
    getDetailSucc (res) {
      res = res.data
      if (res.ret || res.data) {
        const data = res.data
        // console.log('data', data)
        this.sightName = data.sightName
        this.bannerImg = data.bannerImg
        this.gallaryImgs = data.gallaryImgs
        this.List = data.categoryList
      }
      // console.log('res', res)
    }
  },
  mounted () {
    this.getDetailInfo()
  }
}
</script>

<style scoped>
.container{
    height: 55rem;
}
.content{
  position: absolute;
  top: 14.3rem;
  left: 0;
  right: 0;
}
</style>
